package com.study.exception;

import com.study.util.CallResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author CSDN 流放深圳
 * @description 全局的异常捕捉类
 * @create 2024-04-13 15:55
 * @since 1.0.0
 */
@RestControllerAdvice
public class LicenceExceptionAdvance {

    /**
     * 捕捉运行时异常
     * @param exception
     * @return
     */
    @ExceptionHandler(LicenceRuntimeException.class)
    public final CallResult runtimeException(LicenceRuntimeException exception) {
        return CallResult.error(exception.getCode(), exception.getMessage(), exception.getData());
    }

}
